<?php
/**
 * This file contains the class RecentListingsModel which provides
 * most of the code requirements for the recentlistings page
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 */
/**
 * This class provides the code for the recentlistings page
 *
 * @copyright  2009 A Memory Tree
 * @license    A Memory Tree License
 */
class RecentListingsModel
{
    /**
     * Access to the View methods
     *
     * @var RecentListingsView
     */
    private $_view;
    /**
     * Access to the Db methods
     *
     * @var RecentListingsDB
     */
    private $_db;
    /**
     * Access to the Helper methods
     *
     * @var Helper
     */
    private $_helper;
    /**
     * Create a new instance of this class
     *
     * @return void
     * @param RecentListingsDB $db
     * @param RecentListingsView $view
     * @param Helper $helper
     */
    function __construct($db, $view, $helper)
    {
        $this->_db = $db;
        $this->_view = $view;
        $this->_helper = $helper;
    }
    
    function getPeopleList(){
        $list = <<< EOT
            <ul>
                <li style="background:#e4dfcc none repeat scroll 0 0;border:1px solid #cdc8b1;margin:0 0 10px;padding:10px;line-height: 18px;list-style-type:none;">
                    <ul style="overflow: auto;">
EOT;
        $people = $this->_db->getPeople();
        foreach ($people as $id => $person){
            $personLink = "<a href='remembrance.php?personid=".$id."'>".$person['surname'].", ".$person['firstNames']."</a>";
            $list = $list."<li style='list-style-type:none;float:left;display:block;width:256px;border-width:0px;padding:0px;margin:0.25em 0em;'>".$personLink."</li>";
        }
        $list = $list.<<< EOT
                    </ul>
                    <div style="clear:both;"></div>
                </li>
            </ul>
EOT;
        return $list;
    }
    /**
     * Render the page
     *
     * @return string
     */
    function render()
    {
        $helper = $this->_helper;
        $view = $this->_view;
        $content = $view->content($this->getPeopleList());
        return $view->render($content);
    }
}
?>